package com.bishe.controller;


import com.bishe.model.LoginModel;
import com.bishe.pojo.Admin;
import com.bishe.service.AdminService;
import com.bishe.util.JobUtils;
import com.bishe.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lwx
 * @since 2022-04-14
 */
@RestController
@CrossOrigin
@Api(tags = "管理员控制器")
@RequestMapping("/admin")
public class AdminController {

    @Resource
    private AdminService adminService;

    @ApiOperation("admin登录")
    @PostMapping("/login")
    public Result login(@RequestBody LoginModel loginModel){
        //登录效验
        JobUtils.checkLoginModel(loginModel);

        LoginModel login = adminService.login(loginModel);

        if (login!=null){
            return Result.ok("ok",login);
        }
        return Result.error("用户名密码错误!");
    }

}

